package helperClassSearch;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class CreateHMPassDialog {

	public static void CreateUtilsClass(int[] sheetNumbers, String fileName, String packageName, String className) {

		File replacedFile = new File(fileName);
		replacedFile.delete();

		try {
			Workbook workbook = Workbook.getWorkbook(new File("C:\\Documents and Settings\\Administrator\\My Documents\\Dropbox\\CTA\\XLS\\CTA.xls"));
			FileWriter fstream = new FileWriter(fileName);
			BufferedWriter textFile = new BufferedWriter(fstream);


			textFile.write("\n");

			textFile.write("protected static java.util.Map<String, String> passLinkBySiteName = new HashMap<String, String>();\n");
			textFile.write("static {\n");

			for (int d = 0; d < sheetNumbers.length; d++) {
				Sheet sheet = workbook.getSheet(sheetNumbers[d]);
				Cell[] count = sheet.getColumn(0);

				textFile.write("\n");
				for (int j = 1; j < count.length; j++) {
					Cell passSiteNameCell = sheet.getCell(9, j);
					String siteName = passSiteNameCell.getContents();
					Cell passLinkCell = sheet.getCell(35, j);
					String passLinkEN = passLinkCell.getContents();
					textFile.write("passLinkBySiteName.put(\""+ siteName + "\", \""+ passLinkEN + "\");\n");

				}


			}
			textFile.write("}\n");
			textFile.write("}\n");
			textFile.write("\n");

			textFile.close();
		} catch (BiffException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
